<template>
  <section>
    <div class="top">
      <div>
        <p class="top_title">{{title}}</p>
        <p class="top_time">{{time}}</p>
      </div>
      <img src="../../assets/mine/delete.png" class="top_img" @click="delBtn()">
    </div>
    <div class="content">
      <pre v-html="tex" style="white-space: pre-wrap;"></pre>
    </div>

  </section>
</template>

<script>
  export default {
    name:'msgDetail',
    data() {
      return {
        title: '',
        time: '',
        tex: '',
        id:'',
      }
    },
    methods: {
      delBtn(){
        const that = this;
        let arr = [];
        arr.push(this.id.toString())
        this.$dialog.confirm({
          title: '确定删除?',
          mes: '',
          opts: () => {

            that.$ajax.post(window.g.apiUrl+'/account/delNews.do',JSON.stringify({
              idList:arr,
            })).then((response)=>{
              if(response.data.code == 200){
                that.$dialog.notify({
                  mes: '已删除',
                  timeout: 1000,
                  callback:()=>{
                    that.$router.push('/message');
                  }
                });
              }else{
                that.$dialog.notify({
                  mes: '删除失败，请稍后重试',
                  timeout: 1500,
                });
              }
            }).catch(()=>{
            })


          }
        });

      }
    },
    created() {
      const that = this;
      this.$ajax.post(window.g.apiUrl+'/user/isLog.do')
        .then((response)=>{
          if(response.data.code != 200){
            this.$dialog.notify({
              mes: '登录失效，正在跳转至登录页面',
              timeout: 1500,
              callback:()=>{
                that.$router.push('/login');
              }
            });
          }
        }).catch(()=>{
      })

      let MESSAGE_INFO = JSON.parse(sessionStorage.getItem('MESSAGE_INFO'));
      this.title = MESSAGE_INFO.itemTitle;
      this.time = MESSAGE_INFO.itemTime;
      this.tex = MESSAGE_INFO.itemText;
      this.id = MESSAGE_INFO.itemId;


    }
  }
</script>

<style scoped>
  .top {
    margin:0 .24rem 0rem .24rem;
    border-bottom: 1px solid #f2f2f2;
    padding: .2rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .top_title{
    font-size: .34rem;
    font-weight: bold;
    text-align: left;
  }
  .top_time{
    color: #A9A9A9;
    margin-top: .2rem;
    font-size: .3rem;
    text-align: left;
  }
  .content{
    padding: .24rem;
    text-align: left;
    line-height: .6rem;
  }
  .top_img{
    width: .4rem;
    height: .5rem;
  }
  pre{
    font-family: inherit;
  }

</style>
